package com.whatocean.service.impl;

import com.whatocean.dao.AccountDao;
import com.whatocean.domain.Account;
import com.whatocean.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AccountServiceImpl implements AccountService {


    @Autowired
    private AccountDao accountDao;


    @Override
    public void addAccount(Account account) {
        accountDao.addAccount(account);
    }

    @Override
    public void delAccount(Integer id) {
        accountDao.delAccount(id);
    }

    @Override
    public void updateAccount(Account account) {
        accountDao.updateAccount(account);
    }

    @Override
    public Account findById(Integer id) {
        Account byId = accountDao.findById(id);
        return byId;
    }

    @Override
    public List<Account> findAll() {
        List<Account> all = accountDao.findAll();
        return all;
    }

    @Override
    public void transMoney(String fromname,String forname,Double money) {
        accountDao.transMoney(fromname,money);

        accountDao.transMoney(forname,-money);
    }
}
